<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>同步会员信息</title>
    <link rel="stylesheet" href="__STATIC_URL__/static/mobile/css/weui.css" />
    <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
</head>
<style type="text/css">

    .titinfo{
        font-size:14px;
        padding: 10px 15px 0 15px;
    }
    .weui-cells{
        font-size: 14px;
    }

</style>
<body>
<div class="container" id="container">
    <div class="titinfo">
        以下信息必填
    </div>
    <form method="post" id="synchro">
        <div class="weui-cells weui-cells_form">
            <input type="hidden" name="id" value="">
            <input type="hidden" name="card_id" value="{$card['card_id']}" id="cid">
            {eq name="$card['syn_is_exist']" value="1"}
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" name="phone" value="" placeholder="请输入您的手机号" id="phone">
                </div>
            </div>
            {/eq}
            {eq name="$card['syn_is_exist']" value="2"}
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">旧卡号</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" name="old_code" value="" placeholder="请输入您的旧卡号" id="card">
                </div>
            </div>
            {/eq}
        </div>
        <button class="weui-btn weui-btn_primary" type="button" onclick="but();" style="margin-top: 15px;width: 85%;">确认同步</button>
    </form>
     

</div>
<div id="toast" style="display: none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <i class="weui-icon-success-no-circle weui-icon_toast"></i>
        <p class="weui-toast__content" id="msg"></p>
    </div>
</div>
<div class="js_dialog" id="iosDialog2" style="display: none;">
    <div class="weui-mask"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__bd">请填写以上信息</div>
        <div class="weui-dialog__ft">
            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">知道了</a>
        </div>
    </div>
</div>
</body>

<script type="text/javascript">
    function but(){
        $('#iosDialog2').on('click', '.weui-dialog__btn', function(){
            $(this).parents('.js_dialog').fadeOut(200);
        });
        var phone=$("#phone").val();
        var card=$("#card").val();
        var cid=$("#cid").val();
        var $iosDialog2 = $('#iosDialog2')
        if(phone==""||card==""){
            $iosDialog2.fadeIn(200);
            return;
        }

        $.ajax({
            url: "{:url('cardusertest/synusers')}",
            type: 'post',
            async: true,
            data: $("#synchro").serializeArray(),
            success: function (data) {
                console.log(22, data);

                $("#msg").html(data.massage);
                var $toast = $('#toast');

                    if ($toast.css('display') != 'none'){
                        return;
                    }

                    $toast.fadeIn(100);
                    setTimeout(function () {
                        $toast.fadeOut(100);
                    }, 2000);
                if(data.code==0){
                    setTimeout(function () {
                    window.location.reload();
                    }, 2000);
                }
            }
        })
    }

</script>
</html>
